package com.fr.report.web.ui;

import com.fr.base.ArrayUtils;
import com.fr.base.FCloneable;
import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.json.JSONArray;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.Dictionary;
import com.fr.data.Dictionary.MV;
import com.fr.data.core.DataXMLUtils;
import com.fr.report.io.xml.ReportXMLUtils;
import com.fr.report.script.Calculator;
import com.fr.report.script.ParameterMapNameSpace;
import com.fr.web.Repository;
import com.fr.web.core.SessionIDInfor;
import com.fr.web.core.WebUtils;
import com.fr.web.core.service.WidgetService;
import com.fr.web.core.service.WidgetService.DependenceNameSpace;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

public class RadioGroup extends WriteUnableRepeatEditor
{
  private Dictionary mvList;

  public String getXType()
  {
    return "radiogroup";
  }

  public boolean isEditor()
  {
    return false;
  }

  public void setDictionary(Dictionary paramDictionary)
  {
    this.mvList = paramDictionary;
  }

  public Dictionary getDictionary()
  {
    return this.mvList;
  }

  public String[] dependence()
  {
    return ((this.mvList == null) ? new String[0] : this.mvList.getDependence());
  }

  public String[] supportedEvents()
  {
    return ((String[])ArrayUtils.addAll(super.supportedEvents(), new String[] { "statechange" }));
  }

  public JSONArray createJSONData(SessionIDInfor paramSessionIDInfor, Calculator paramCalculator, HttpServletRequest paramHttpServletRequest)
    throws Exception
  {
    JSONArray localJSONArray = super.createJSONData(paramSessionIDInfor, paramCalculator, paramHttpServletRequest);
    if (this.mvList == null)
      return localJSONArray;
    paramCalculator.pushNameSpace(ParameterMapNameSpace.create(paramSessionIDInfor.getParameterMap4Execute()));
    paramCalculator.pushNameSpace(new WidgetService.DependenceNameSpace(WebUtils.getHTTPRequestParameter(paramHttpServletRequest, "dependence")));
    this.mvList.reset();
    Iterator localIterator = this.mvList.entrys(paramCalculator);
    ArrayList localArrayList = new ArrayList();
    while (true)
    {
      String str1;
      String str2;
      while (true)
      {
        Dictionary.MV localMV;
        do
        {
          do
          {
            if (!(localIterator.hasNext()))
              break label218;
            localMV = (Dictionary.MV)localIterator.next();
            str1 = WidgetService.toJSONString(localMV.getModel(), paramHttpServletRequest);
            str2 = WidgetService.toJSONString(localMV.getView(), paramHttpServletRequest);
          }
          while (!(StringUtils.isNotEmpty(str2)));
          if (!(isRemoveRepeat()))
            break label188;
        }
        while (localArrayList.contains(localMV));
        localJSONArray.put(new JSONObject().put("value", str1).put("text", str2));
        localArrayList.add(localMV);
      }
      label188: localJSONArray.put(new JSONObject().put("value", str1).put("text", str2));
    }
    label218: return localJSONArray;
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("Dictionary"))
        this.mvList = DataXMLUtils.readXMLDictionary(paramXMLableReader);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (this.mvList != null)
      ReportXMLUtils.writeXMLable(paramXMLPrintWriter, this.mvList, "Dictionary");
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof RadioGroup) && (super.equals(paramObject)) && (ComparatorUtils.equals(this.mvList, ((RadioGroup)paramObject).mvList)));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    RadioGroup localRadioGroup = (RadioGroup)super.clone();
    if (this.mvList != null)
      localRadioGroup.mvList = ((Dictionary)this.mvList.clone());
    return localRadioGroup;
  }
}